/**
 * permet de dwnloader un podcast dans Video, puis de le jouer avec Vlc
 * needs pluzzdl + mimms
 */

import QtQuick 1.0
import "/usr/share/libsocmdc/kdeadmouseutils-build-desktop"
Item {
  property string url : 'http://www.pluzz.fr/l-organisation-secrete-des-fourmis.html'
  //'http://www.pluzz.fr/plus-belle-la-vie-2012-06-27-20h10.html'
  property string fileName
  signal allFinished()
  id:mainItem
  
  ShellInvoker {
    id : shellPluzzdl
    wDir:setting.value('homeVideo');
    property int state:0
    onFinished : {
      console.log('#pluzz#>onFinished');
      return;
      if(0==state){
	state=1;
	shellAction('pluzzdl',['-f',url]);
	return;
      }
   }
    
   onOutputLineChanged : {
	console.log('#pluzz#>: ' + outputLine);
   }
  }
  
  function findmmsUrl(line){
    var pattern = / (mms:.*)$/;
    var outPattern = pattern.exec(outputLine);
    mmsUrl=outPattern[1];
    console.log('mms found <' +mmsUrl+'>');
    return mmsUrl;
  }
  
  QmlSetting{
    id:setting
    appName:'pluzz'
  }
  
  Component.onCompleted: {
    shellPluzzdl.state=0;
    var namePod = /www.pluzz.fr\/(.*)\.html/.exec(url)[1];
    //console.log('<'+namePod+'>');
    mainItem.fileName=namePod + '.flv';
    shellPluzzdl.shellAction('pwd',[]);
    //shellPluzzdl.shellAction('cd',[]);
  }
  
    
}
